package com.pianzhu.blockchainemr.controller;

import com.pianzhu.blockchainemr.pojo.EmrUser;
import com.pianzhu.blockchainemr.pojo.Param.LogoutParam;
import com.pianzhu.blockchainemr.pojo.result.Result;
import com.pianzhu.blockchainemr.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService loginService;
    @PostMapping
    public Result login(@RequestBody EmrUser emrUser) {
        return Result.success(loginService.login(emrUser));
    }
    @PostMapping("/logout")
    public Result logout(@RequestBody LogoutParam user) {
        loginService.logout(user.getUsername());
        return Result.success();
    }
}
